package com.linsir.ext.beetl;

import org.beetl.core.Context;
import org.beetl.core.Function;

/**
 * @author linsir
 * @title: IsTrueFun
 * @projectName linsir-mu
 * @description: 自定判断是否为True
 * @date 2021/12/3 22:55
 */
public class IsTrueFun implements Function {

        public Object call(Object[] paras, Context ctx) {
                if (paras.length != 1) {
                        throw new RuntimeException("参数错误，期望Object");
                }
                Object para = paras[0];
                if (para == null) {
                        return false;
                }
                if (para.toString().equalsIgnoreCase("true")) {
                        return true;
                }
                if (para.toString().equals("1")) {
                        return true;
                }
                return false;
        }
}
